home *** CD-ROM | disk | FTP | other *** search
- Path: darkstar.UCSC.EDU!kama!jono
- From: jono@cse.ucsc.edu (Jonathan Gibbs)
- Newsgroups: comp.lang.c++
- Subject: Templates & protected
- Date: 8 Feb 1996 22:15:42 GMT
- Organization: UC Santa Cruz CIS/CE
- Message-ID: <4fdsme$9ba@darkstar.UCSC.EDU>
- NNTP-Posting-Host: kama.cse.ucsc.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- I know the if class B is derived from class A, then B can see A's
- protected members, but what if B and A are templated as follows:
-
- template <int T>
- class A
- {...};
-
- template <int U>
- class B : public A<2>
- {...};
-
- I assume all B's can see A<2>'s protected members, but can it see
- A<3>'s? g++ says not. Is there any way around this?
-
- Real Sample code & error:
-
- template <class TYPE, int SIZE>
- class Vector {...
-
- template <class TYPE, int ROWS, int COLS>
- class Matrix : public Vector<TYPE, ROWS*COLS> {...
-
- Error:
- matrix.h:
- In method `class Matrix<float,3,3>
- Matrix<float,3,3>::tilde(class Vector<float,3> &)':
- 146: member `_data' is a protected member of class `Vector<float,3>'
-
- HELP!
-
- --
- "The human mind is a dangerous plaything, boys. When it's used for evil,
- watch out! But when it's used for good, then things are much nicer."
- -- The Tick
- <Home Page: http://www.cse.ucsc.edu/~jono>
-